<?php


namespace app\admin\controller\setup;


use app\common\controller\Backend;
use app\Request;

class FreeDeliveryRules extends Backend
{
    /**
     * @var $freeDeliveryRulesService \app\admin\service\FreeDeliveryRules
     */
    protected $freeDeliveryRulesService = null;

    /**
     * Notes:
     * DateTime 2021/5/7 17:11
     * @Author Hunter
     */
    protected function initialize()
    {
        parent::initialize();
        $this->freeDeliveryRulesService = new \app\admin\service\FreeDeliveryRules();
    }

    /**
     * Notes:首页
     * DateTime 2021/5/7 17:13
     * @Author Hunter
     * @return \think\response\Json
     */
    public function index()
    {
        return $this->freeDeliveryRulesService->getList();
    }

    /**
     * Notes:添加
     * DateTime 2021/5/7 17:37
     * @Author Hunter
     * @return \think\response\Json
     */
    public function add(Request $request)
    {
        return $this->freeDeliveryRulesService->createBy();
    }

    /**
     * Notes:编辑
     * DateTime 2021/5/7 17:36
     * @Author Hunter
     * @return \think\response\Json
     */
    public function edit(Request $request)
    {
        $id = $request->param('id');
        $param = $request->param();
        return $this->freeDeliveryRulesService->updateBy($id, $param);
    }

    /**
     * Notes:删除
     * DateTime 2021/5/7 17:55
     * @Author Hunter
     * @param Request $request
     * @return \think\response\Json
     */
    public function delete(Request $request)
    {
        $id = $request->param('id');
        return $this->postageRulesService->delete($id);
    }
}